import { getReceiptList } from '../services/receipt'
export default {
  namespace: 'receipt',
  state: {
    receiptList: null,
    pageSize: null,
    lastPage: null,
    page: null,
    total: null

  },
  effects: {
    *apiGetReceiptList({ payload }, { call, put }) {
      const response = yield call(getReceiptList, payload)
      if (response.error == 0) {
        yield put({
          type: 'setState', payload: {
            receiptList: response.data.data,
            pageSize: response.data.perPage,
            page: response.data.page,
            total: response.data.total,
            lastPage: response.data.lastPage
          }
        })
      }
      console.log(response, 'response')
    }
  },
  reducers: {
    setState(state, { payload }) {
      return {
        ...state,
        ...payload,
      }
    }
  }
}